package mn.idax.exchange.otc.service.impl;

import mn.idax.exchange.otc.entity.JPushLog;
import mn.idax.exchange.otc.entity.User;
import mn.idax.exchange.otc.mapper.JPushLogMapper;
import mn.idax.exchange.otc.service.JPushLogService;
import mn.idax.exchange.otc.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author: jack_huang
 * @Date: 2019/4/2 17:22
 */
@Service
public class JPushLogServiceImpl implements JPushLogService {

    private static final Logger LOGGER = LoggerFactory.getLogger(JPushLogServiceImpl.class);

    @Autowired
    private JPushLogMapper jPushLogMapper;

    @Autowired
    private UserService userService;

    @Override
    public  List<JPushLog> getSystemMessage(Integer userId) {
        User user = userService.getUserById(userId);
        return jPushLogMapper.getSystemMessage(user.getEmail());
    }

    @Override
    public Integer updateJpushLog(Integer id, Date utcNow) {

        return jPushLogMapper.updateJpushLog(id,utcNow);
    }

    @Override
    public  List<Integer> getUnReadSystemMessage(Integer userId) {
        User user = userService.getUserById(userId);
        return jPushLogMapper.getUnReadSystemMessage(user.getEmail());
    }

    @Override
    public Integer updateJpushLogsToRead(List<Integer> ids, Date utcNow) {
        return jPushLogMapper.updateJpushLogsToRead(ids,utcNow);
    }

}
